package cn.com.api.mapper;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import cn.com.api.entity.ApiU_template;
import cn.com.api.mapper.base.U_templateMapperBase;

//DAO
public interface ApiU_templateMapper extends U_templateMapperBase {

	// 新增对象后返回记录ID
	public int U_templateInsertion(ApiU_template u_template);

	// 添加
	@Insert("INSERT INTO U_TEMPLATE (TPL_NAME, TPL_THUMB, BG_IMAGE, BG_AUDIO, TYPE, TPL_DESC, TPL_LEVEL, CREATE_TIME, CREATE_BY, MODIFY_TIME, MODIFY_BY, STATUS, CONTROLLER_ROUTE, THEME, PARAMETERS) "
			+ "VALUES "
			+ "(#{tpl_name,jdbcType=VARCHAR}, #{tpl_thumb,jdbcType=VARCHAR}, #{bg_image,jdbcType=VARCHAR}, #{bg_audio,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{tpl_desc,jdbcType=VARCHAR}, #{tpl_level,jdbcType=VARCHAR}, #{create_time,jdbcType=VARCHAR}"
			+ ", #{create_by,jdbcType=VARCHAR}, #{modify_time,jdbcType=VARCHAR}, #{modify_by,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{controller_route,jdbcType=VARCHAR}, #{theme,jdbcType=VARCHAR}, #{parameters,jdbcType=VARCHAR})")
	@Options(useGeneratedKeys = true, keyProperty = "")
	public int insertU_template_info(ApiU_template u_template);

	@Select("SELECT * FROM U_TEMPLATE where template_id = #{template_id}")
	public ApiU_template findU_templateByTemplateId(Integer template_id);

	@Update("UPDATE U_TEMPLATE SET "
			+ "TPL_NAME = #{tpl_name}, TPL_THUMB = #{tpl_thumb}, BG_IMAGE = #{bg_image}, BG_AUDIO = #{bg_audio}, TYPE = #{type}, "
			+ "TPL_DESC = #{tpl_desc}, TPL_LEVEL = #{tpl_level}, CREATE_TIME = #{create_time}, CREATE_BY = #{create_by}, "
			+ "MODIFY_TIME = #{modify_time}, MODIFY_BY = #{modify_by}, STATUS = #{status}, CONTROLLER_ROUTE = #{controller_route}, "
			+ "THEME = #{theme}, PARAMETERS = #{parameters}, "
			+ "EXT_1 = #{ext_1}, EXT_2 = #{ext_2}, EXT_3 = #{ext_3}, EXT_4 = #{ext_4}, EXT_5 = #{ext_5}"
			+ "where TEMPLATE_ID = #{template_id}")
	public int updateU_template_info(ApiU_template u_template);

	// 根据模块类型查询模版列表
	public List<Map<String, Object>> findU_templates_type(@Param("type") String type);

	// 根据模块类型查询模版列表
	public List<ApiU_template> findTemplatesByType(@Param("type") String type);

	@Delete("DELETE FROM U_TEMPLATE WHERE TEMPLATE_ID = #{template_id}")
	public int deleteU_template_info(Integer template_id);

}
